home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 2
/
Nebula Two.iso
/
SourceCode
/
MiscKit1.7.1
/
MiscKitArchive.mbox
/
mbox
/
000066_d89cb@efd.lth.se_Tue Oct 12 06:15 MDT 1993.msg
< prev
next >
Wrap
Internet Message Format
|
1994-10-30
|
6KB
Received: from yvax.byu.edu by maine.et.byu.edu; Tue, 12 Oct 93 06:15:13 -0600
Return-Path: <d89cb@efd.lth.se>
Received: from DIRECTORY-DAEMON by yvax.byu.edu (PMDF V4.2-13 #4169) id
<01H40JT2RWTS94M1L4@yvax.byu.edu>; Tue, 12 Oct 1993 06:13:13 MDT
Received: from alaska.et.byu.edu by yvax.byu.edu (PMDF V4.2-13 #4169) id
<01H40JSYUCJK9BVPFU@yvax.byu.edu>; Tue, 12 Oct 1993 06:13:07 MDT
Received: from yvax.byu.edu by alaska.et.byu.edu; Tue, 12 Oct 93 06:14:49 -0600
Received: from DIRECTORY-DAEMON by yvax.byu.edu (PMDF V4.2-13 #4169) id
<01H40JSM1QKW94M1L4@yvax.byu.edu>; Tue, 12 Oct 1993 06:12:50 MDT
Received: from efd.lth.se (oddput.efd.lth.se) by yvax.byu.edu (PMDF V4.2-13
#4169) id <01H40JSHLVJK9BVOND@yvax.byu.edu>; Tue, 12 Oct 1993 06:12:44 MDT
Received: from neptunus-6.efd.lth.se by efd.lth.se with smtp (Smail3.1.28.1 #1)
id m0omib7-0002VeC; Tue, 12 Oct 93 13:13 MET
Received: by neptunus-6.efd.lth.se (Smail3.1.28.1 #3) id m0omiae-0000RMC; Tue,
12 Oct 93 13:12 MET
Date: Tue, 12 Oct 1993 13:12 +0100 (MET)
From: d89cb@efd.lth.se (Christian Brunschen)
Subject: Am I insane ?
To: misckit@byu.edu
Message-Id: <m0omiae-0000RMC@neptunus-6.efd.lth.se>
X-Mailer: Mail User's Shell (7.2.4 2/2/92)
Content-Transfer-Encoding: 7BIT
Status: RO
You know, I've had a really wild idea. The kind of idea that will be
discribed as either "insane" or "insanely great".
Let me give you some background:
Our university has recently installed 50 Sun SPARCclassic machines --
the first machines on campus that have actual sound support (no NeXTen
on campus here, alas). We are running, on these machines, Solaris 2.1
-- ie, SunOS 5.2 -- but under vanilla X11R5, using twm as a window
manager.
An immediate side effect of sound-aware machines showing up was that
people have started associating sounds with actions in the window
manager: A friend of mine has a gun-shot sound for the window-kill
function. To achieve this, he created a function of his own (winkill)
which plays the sound and kills the window using twm:s f.kill
function. He then replaced all calls to f.kill with calls to his own
winkill.
What he did was basically, subclass twm, and override the f.kill
function.
This was not difficult in any way. However, I could not do that under
NeXTSTEP with the current set of tools available. Oh, sure, I could
open every .nib file in my entire file system and drop "bang.snd" on
the close button of every window. But this is a non-general way of
doing it and requres much work on my part -- and I have to redo _all_
the work if I want to use another sound, or do something else than
just play a sound.
(So, where's the really neat idea? Coming real soon, promise :-)
What I would _really_ like to do is replace the Window class, as it is
in the system, with a subclass that I have defined myself. Obviously,
I don't have the source code to most applications, so this approach
doesn't appear very workable. Or is it? Hmmm... Waitasec .. Ah! Bingo!
there it is ... "poseAs"!
OK, now we have a way to replace one class by a subclass; There is one
restriction -- we can't add any instance varibales -- but that should
be possible to circumvent if we absolutely _have_ to, so no big deal.
We also know how to load classes -- NXBundle is there to help us.
So, what we need is simple a way to, automatically at application
startup, do the following:
* Check the defaults database for which classes should be replaced,
and which classes should take their places
* Load each replacementclass (an NXBundle, most likely)
* Send each replacement class the respective +poseAs: message
All of this must, of course, be done before we have started using any
of the classes we replace.
So, we create a class -- preferrably a subclass of Application -- that
does all of this; we could place it in Application's +initialize
method, so it will be done before (almost) anything else.
We use this MiscApplication class instead of Application in our
applications. And now, I can simply create my own subclass of Window
that goes "KaBLAM!" when it is closed, put this class in an NXBundle,
do a dwrite (something like "dwrite GLOBAL replacementClasses
BlamWindow:Window" perhaps) and every application that uses
MiscApplication will automatically use the BlamWindow class instead of
plain old Window -- even in their own subclasses of Window! (For
details on this, consult documentation -- and please point out any
errors that I have made in my reasoning.)
(Why am I not being more detailed? Beacuse I am not sure about the
details! :)
What's _really_ neat about this is that it can be made to work for
arbitrary classes -- ie, you could replace Object with a version that
prints debugging info, or something. (Of course, in most applications
this isn't really something we want J. Random User to do, so some kind
of security system (like, "don't replace any classes that are above
View in the class hierarchy") should be implemented as well.) This is
en _extremely_ general and powerful way of customizing application
behaviour to suit your needs -- not only can you have a window that
goes BLAM everytime you close it, you can also (for instance) have a
scroller give you audio feedback as to its position (shouldn't be too
hard to do, should it? Let it make a sound with a frequency (or
volume) that is calculated from where the scroller is ... and you
automatically get it in _every app_ that uses the MiscApplication
object, not just apps where the implementor thought this would be a
cool idea! :-) !!
How does this help me with existing applications? It doesn't. But
since this idea is so damn general, maybe we could convince people to
start using it in their applications.
Any comments ? Is this insane, or insanely great ?
Best regards
// Christian Brunschen
| Christian Brunschen, Husmansv. 26, S-227 38 Lund, Sweden |
| voice/fax/data +46 (0)46 139345, email d89cb@efd.lth.se |
| PGP 2.2 Public Key available on request. | ObCelebrityQuote: |
| "Oh, foo." |
| - Andrew R. Koenig (ark@research.att.com) after dropping a piece |
| of chalk during a lecture on C++ in Lund, Sweden, April 1993 |